/*
 * @lc app=leetcode.cn id=11 lang=java
 *
 * [11] 盛最多水的容器
 */

// @lc code=start
class Solution {
    public int maxArea(int[] height) {
        int len = height.length;
        int l = 0, r = len-1;
        int ans = 0;
        while(l < r){
            int sum = (r - l) * min(height[l], height[r]);
            if(height[l] < height[r]) {
                l++;
            } else {
                r--;
            }
            ans = max(sum, ans); 
        }

        return ans;

    }
    private int max(int a, int b){
        if (a > b){
            return a;
        }
        return b;
    }
    private int min(int a, int b){
        if (a < b){
            return a;
        }
        return b;
    }
}
// @lc code=end

